////////////////////////////////////////////////////////////////////////////////
//
//	Original file Name: Tile.java
//	Originating Author: JWhitefield
//	
//	Description: Represents a single game tile 
//
////////////////////////////////////////////////////////////////////////////////

package com.jjw.game.world.tile;

import com.jjw.game.graphics.Sprite;
import com.jjw.game.screen.IRenderable;
import com.jjw.game.screen.Screen;

public class Tile implements IRenderable {
	
	//--------------------------------------------------------------------------
	//
	//Properties
	//
	//--------------------------------------------------------------------------
	
	//----------------------------------
	// Tile Constants
	//----------------------------------

	//TILE DEFAULT SIZE
	public static final int DEFAULT_TILE_SIZE = 32;
	
	//BLANK TILE
	public static final String BLANK = "0";
	
	//TERRAIN TILES
	public static final String TERRAIN_GRASS_TILE = "t1";
	
	//----------------------------------
	// Public
	//----------------------------------
	
	//----------------------------------
	//  Getters / Setters
	//----------------------------------

	/**
	 * The id of the tile 
	 */
	public String getTileId() {
		return tileId;
	}

	private void setTileId(String tileId) {
		this.tileId = tileId;
	}
	
	/**
	 * The default sprite for this tile 
	 */
	public Sprite getCurrentSprite() {
		return currentSprite;
	}

	private void setCurrentSprite(Sprite defaultSprite) {
		this.currentSprite = defaultSprite;
	}
	
	//----------------------------------
	// Private
	//----------------------------------

	/**
	 * The id of the tile 
	 */
	private String tileId;
	
	/**
	 * The default sprite for this tile 
	 */
	private Sprite currentSprite;
	
	//--------------------------------------------------------------------------
	//
	//  Methods
	//
	//--------------------------------------------------------------------------
	
	public Tile( String tileId, Sprite defaultSprite ) {
		
		//Set the default properties 
		this.setTileId( tileId );
		this.setCurrentSprite(defaultSprite);
	}

	//----------------------------------
	// Public
	//----------------------------------
	
	//----------------------------------
	// Private
	//----------------------------------
	
	//----------------------------------
	// Overridden / Implemented
	//----------------------------------
	
	@Override
	public void render(Screen screen, int x, int y) {
		
		//If we don't have a current sprite we can't render it to the screen
		if( this.currentSprite == null )
			return;
		
		//Render the current sprite to the screen 
		screen.render(x, y, this.currentSprite);
	}
}
